package com.lagou.boot;

import com.lagou.server.UserServiceImpl;
import com.lagou.zookeeper.config.ConfigKeeper;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;

@SpringBootApplication
@ComponentScan(value = "com.lagou")
public class ServerBootstrap {
    public static void main(String[] args) {
        // ["localhost:2181","8999"]
        // ["localhost:2181","9000"]

        final String zkPath = args[0];
        final int nettyPort = Integer.parseInt(args[1]);

        // 将IP及端口信息注册到Zookeeper
        ConfigKeeper configKeeper = ConfigKeeper.getInstance();
        configKeeper.setProviderSide(true);
        configKeeper.setInterval(5);
        configKeeper.setNettyPort(nettyPort);
        configKeeper.setZkAddr(zkPath);
        System.out.println(configKeeper);


        SpringApplication.run(ServerBootstrap.class, args);

        // 启动服务器
        UserServiceImpl.startServer("localhost",8090);
    }
}
